package Command;

import java.util.ArrayList;

import Server.Command;
import Server.cmdArguments;

public class CommitCommand implements Command, Runnable{
	private cmdArguments args;
	
	public CommitCommand(){}
	
	@Override
	public String execute() {	
		while(!args.ds.isEmpty()){		
			
			ArrayList<Integer> actionList =  new ArrayList<Integer>();
			while(!args.ds.isEmpty()){
				actionList.add(args.ds.removeFirst());
			}
			args.da.insert(args.actionList);
			args.ds.clear();
			return "Every insert has been added to the databasequeue";
			
		}	
		System.out.println("This actionList has " + args.ds.size() + " entries");
		return "There was nothing on the queue";		
	}

	@Override
	public String undo() {
		/*
		 * In deze functie moeten de functies die op de queue zijn gezet weer erafgehaald worden.
		 */
		return null;
	}

	@Override
	public void setArgs(cmdArguments args) {
		this.args = args;
	}

	@Override
	public void run() {		
		
	}
	
	
}